<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
	<META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=utf-8">
	<TITLE></TITLE>
	<META NAME="GENERATOR" CONTENT="OpenOffice.org 3.2  (Unix)">
	<META NAME="CREATED" CONTENT="0;0">
	<META NAME="CHANGED" CONTENT="20110101;14462800">
	<STYLE TYPE="text/css">
	<!--
		@page { margin: 0.79in }
		P { margin-bottom: 0.08in }
		PRE { font-family: "Times New Roman" }
	-->
	</STYLE>
</HEAD>
<BODY LANG="el-GR" DIR="LTR">
<PRE LANG="en-US"><FONT SIZE=5><B>Symmetric matrices – Iterative improvement</B></FONT>

<FONT SIZE=5><SPAN LANG="en-US"><B>symeigimp</B></SPAN></FONT>


<FONT SIZE=4><SPAN LANG="en-US"><SPAN STYLE="font-style: normal">for</SPAN> details see book of Hang T. Lau, “A Java Numerical Library for Scientists and engineers|”, Chapman &amp; Hall, 2004</SPAN></FONT>

<FONT SIZE=4><SPAN LANG="en-US"><B>Example: Can be run with F5 within the ScalaLab Editor (Ctrl-E to open the editor)</B></SPAN></FONT>



<SPAN LANG="en-US">import java.text.DecimalFormat;</SPAN>
<SPAN LANG="en-US">import numal.*;</SPAN>

<SPAN LANG="en-US">public class Test_symeigimp extends Object {</SPAN>
<SPAN LANG="en-US">	</SPAN>
<SPAN LANG="en-US">	public static void main(String args[]) {</SPAN>

    <SPAN LANG="en-US">int i,j;</SPAN>
    <SPAN LANG="en-US">double val[] = new double[5];</SPAN>
    <SPAN LANG="en-US">double lbound[] = new double[5];</SPAN>
    <SPAN LANG="en-US">double ubound[] = new double[5];</SPAN>
    <SPAN LANG="en-US">double em[] = new double[6];</SPAN>
    <SPAN LANG="en-US">double aux[] = new double[6];</SPAN>
    <SPAN LANG="en-US">double a[][] = new double[5][5];</SPAN>
    <SPAN LANG="en-US">double x[][] = new double[5][5];</SPAN>

    <SPAN LANG="en-US">a[1][1]=a[2][2]=a[3][3]=a[4][4]=6.0;</SPAN>
    <SPAN LANG="en-US">a[1][2]=a[2][1]=a[3][1]=a[1][3]=4.0;</SPAN>
    <SPAN LANG="en-US">a[4][2]=a[2][4]=a[3][4]=a[4][3]=4.0;</SPAN>
    <SPAN LANG="en-US">a[1][4]=a[4][1]=a[3][2]=a[2][3]=1.0;</SPAN>
    <SPAN LANG="en-US">for (i=1; i&lt;=4; i++)</SPAN>
      <SPAN LANG="en-US">for (j=i; j&lt;=4; j++) x[i][j]=x[j][i]=a[i][j];</SPAN>
    <SPAN LANG="en-US">em[0]=1.0e-6; em[4]=100.0;  em[2]=1.0e-5;</SPAN>
    <SPAN LANG="en-US">Linear_algebra.qrisym(x,4,val,em);</SPAN>
    <SPAN LANG="en-US">aux[0]=0.0;   aux[4]=10.0;  aux[2]=1.0e-6;</SPAN>
    <SPAN LANG="en-US">Linear_algebra.symeigimp(4,a,x,val,lbound,ubound,aux);</SPAN>
    <SPAN LANG="en-US">DecimalFormat fiveDigit = new DecimalFormat(&quot;0.00000E0&quot;);</SPAN>
    <SPAN LANG="en-US">System.out.println(&quot;\nThe exact eigenvalues are:  -1,  5,  5,  15\n\n&quot; +</SPAN>
      <SPAN LANG="en-US">&quot;The computed eigenvalues:\n  &quot; +</SPAN>
      <SPAN LANG="en-US">fiveDigit.format(val[1]) + &quot;\n   &quot; +</SPAN>
      <SPAN LANG="en-US">fiveDigit.format(val[2]) + &quot;\n   &quot; +</SPAN>
      <SPAN LANG="en-US">fiveDigit.format(val[3]) + &quot;\n   &quot; +</SPAN>
      <SPAN LANG="en-US">fiveDigit.format(val[4]) +</SPAN>
      <SPAN LANG="en-US">&quot;\n\n Lowerbounds   Upperbounds\n &quot; +</SPAN>
      <SPAN LANG="en-US">fiveDigit.format(lbound[1]) + &quot;   &quot; +</SPAN>
      <SPAN LANG="en-US">fiveDigit.format(ubound[1]) + &quot;\n &quot; +</SPAN>
      <SPAN LANG="en-US">fiveDigit.format(lbound[2]) + &quot;   &quot; +</SPAN>
      <SPAN LANG="en-US">fiveDigit.format(ubound[2]) + &quot;\n &quot; +</SPAN>
      <SPAN LANG="en-US">fiveDigit.format(lbound[3]) + &quot;   &quot; +</SPAN>
      <SPAN LANG="en-US">fiveDigit.format(ubound[3]) + &quot;\n &quot; +</SPAN>
      <SPAN LANG="en-US">fiveDigit.format(lbound[4]) + &quot;   &quot; +</SPAN>
      <SPAN LANG="en-US">fiveDigit.format(ubound[4]) + </SPAN>
      <SPAN LANG="en-US">&quot;\n\nNumber of iterations = &quot; + (int)aux[5] +</SPAN>
      <SPAN LANG="en-US">&quot;\nInfinity norm of A   = &quot; + (int)aux[1] + </SPAN>
      <SPAN LANG="en-US">&quot;\nMaximum absolute element of residu = &quot; + </SPAN>
      <SPAN LANG="en-US">fiveDigit.format(aux[3]));</SPAN>
<SPAN LANG="en-US">	}</SPAN>
<SPAN LANG="en-US">}</SPAN>

</PRE>
</BODY>
</HTML>